<?php

include_once ('./library/libconnect.php');
include_once ('./library/common.php');

$conn = new libconnect();
$conn->inicializar($dbhost, $user, $pwd, $databaseorigen, '', $database);
$conn->libconnect();

mysql_query("BEGIN", $conn->db);

//$sql = " UPDATE conciliacion_formularios SET nro_serie_completo = '6605100023537055' WHERE repart_id = '1' AND serie_id = '1' and articulo_id = '110' and dep_id = 70 and nro_serie = 2353705 ";

//$sql = "update formularios_inexistentes set dep_id = 6033 where repart_id = '1' and serie_id = '1' and articulo_id = '100' and nro_serie BETWEEN 2823001 and 2827000";

$sql = " UPDATE mensajes SET leido = 1 WHERE id = 2612 ";

//$sql = " DELETE FROM conciliacion_formularios WHERE repart_id = '1' AND serie_id = '1' AND articulo_id = '100' AND nro_serie = 2480746 ";

//$sql = " DELETE FROM rendicion_formularios WHERE repart_id = '1' AND serie_id = '1' AND articulo_id = '100' AND nro_serie = 2480746 ";

//$sql = " DELETE FROM mvtos_formularios WHERE repart_id = '1' AND serie_id = '1' AND articulo_id = '100' AND nro_serie = 2480746 AND estado_paquete = '7' ";

//$sql = " UPDATE detalle_formularios SET nro_serie_completo = '6605300011367385' WHERE repart_id = '1' AND serie_id = '1' and articulo_id = '100' and dep_id = 2951 and nro_serie = 1136738 ";

//$sql = " UPDATE rendicion_formularios SET tramite_form_id = '999' WHERE repart_id = '1' AND serie_id = '1' and articulo_id = '100' and dep_id = 2951 and nro_serie = 1136738 ";

/*$sql = "DELETE FROM mensajes";*/

/*$sql = "

CREATE VIEW `dga`.`norecaudadas` AS
    (SELECT rf.nro_serie, rf.articulo_id, rf.dep_id, rf.cod_ente_recau , rf.tasa, rf.fecha_toma
	FROM rendicion_formularios rf
		inner join conciliacion_formularios cf
		on cf.repart_id = rf.repart_id
		and cf.nro_serie = rf.nro_serie
		and cf.serie_id = rf.serie_id
		AND cf.articulo_id = rf.articulo_id
		AND cf.conciliacion_id = '3'
	WHERE rf.repart_id = '1'
		AND rf.serie_id = '1'
		AND rf.tramite_form_id = '999'
		AND rf.articulo_id in ('117','116','110','100','121','111','112','113','114','115')
)

";*/

/*$sql = "
CREATE VIEW `dga`.`conciliadas` 
    AS
    (
	SELECT articulo_id, nro_serie, dep_id , importe, conciliacion_id, fecha_pago FROM conciliacion_formularios
	WHERE repart_id = '1'
	AND serie_id = '1' 
	AND conciliacion_id in ('1','2')
        AND articulo_id in ('117','116','110','100','121','111','112','113','114','115')
)    
";*/

//$sql = "update resumen_rendiciones set periodo_id = 20 where periodo_id = 4 and mes = 4";

//$sql = " UPDATE apps SET url = 'http://www.gob.gba.gov.ar/intranet/sist/S_Prenumeradas/ini.php' where app_id = '21' ";

//http://server8.gob.gba.gov.ar/intranet/sist/S_Prenumeradas/Principal.php

//$sql = " UPDATE apps SET url = 'server8.gob.gba.gov.ar/intranet/sist/S_Prenumeradas/Principal.php' WHERE app_id = '21' ";

//$sql = " UPDATE articulos SET inicio = 0, cant_digitos = 25 WHERE articulo_id = '117' AND rubro_id = '4' AND repart_id = '1' ";

/*$sql = " UPDATE per_usr set app_id = '2', perfil_id = '1' WHERE username = 'rbustos'";*/
/*$sql = " UPDATE operador SET repart_id = '1' WHERE username = 'rbustos'";*/

//$sql = " OPTIMIZE TABLE conciliacion_formularios ";


//$sql = "UPDATE detalle_formularios SET dep_id = 260 WHERE repart_id = '1' AND articulo_id = '116' AND serie_id = '1' AND nro_serie BETWEEN 90471501 and 90472000 ";
//$sql = "UPDATE rendicion_formularios SET dep_id = 157 WHERE repart_id = '1' AND articulo_id = '116' AND serie_id = '1' AND nro_serie BETWEEN 92298001 and 92299000  ";
//$sql = "UPDATE formularios_inexistentes SET dep_id = 133 WHERE repart_id = '1' AND articulo_id = '116' AND serie_id = '1' AND nro_serie BETWEEN 92299001 and 92300000   ";
//$sql = "UPDATE conciliacion_formularios SET dep_id = 260 WHERE repart_id = '1' AND articulo_id = '116' AND serie_id = '1' AND nro_serie BETWEEN 90471501 and 90472000 ";


/*$sql = "INSERT INTO usr_deleg (app_id, dep_id, user_id)
        VALUES ('21', 113, 230)";*/
/*$sql = "DELETE FROM usr_deleg WHERE app_id = '21' AND dep_id = 113 AND user_id = 230 ";*/

/*$sql = "INSERT INTO usr_deleg (app_id, dep_id, user_id)
        VALUES ('21', 6100, 338),('21', 6100, 226),('21', 6100, 302),('21', 6100, 339),('21', 6100, 257),('21', 6100, 227)
        ,('21', 6100, 301),('21', 6100, 251)";*/
/*$sql = "INSERT INTO per_usr (app_id, perfil_id, username)
        VALUES ('21', '3', 'operador1')";*/
/*$sql = "INSERT INTO operador (username, repart_id, org, apyn, password, maxtime, activo)
        VALUES ('operador1', '1', '6000', 'operdor prueba', '".md5("operador1")."', 6000, 'S')";*/


/*$sql = "UPDATE detalle_formularios SET dep_id = 6033 WHERE repart_id = '1'
AND serie_id = '1'
AND articulo_id IN ('100')
AND dep_id = 3066
AND nro_serie = 1746457 ";*/

/* se remplazo de las conciliaciones la dependencia de 2854 por 3275 */
/* se remplazo de las conciliaciones la dependencia de NN por 7059 */
//$sql = "UPDATE conciliacion_formularios SET dep_id = 3275 WHERE repart_id = '1' AND articulo_id = '116' AND serie_id = '1' AND nro_serie BETWEEN 92639001 AND 92640000 ";
/*
$sql = "UPDATE conciliacion_formularios SET dep_id = 3381 WHERE repart_id = '1' AND articulo_id = '116' AND serie_id = '1' AND nro_serie BETWEEN 92478001 and 92479000 ";
*/
/*$sql = "DELETE FROM conciliacion_formularios 
        WHERE repart_id = '1'
        AND serie_id = '1'
        AND ISNULL(id_archivo)
        AND conciliacion_id = '1'
        AND articulo_id IN ('100','110')";
 
 
//$sql = "UPDATE articulos SET prefijo = '6605'  WHERE rubro_id = '4' AND articulo_id IN ('100','110')";

//$sql = "UPDATE formularios_inexistentes SET dep_id = 7059 WHERE repart_id = '1' AND articulo_id = '116' AND serie_id = '1' AND nro_serie BETWEEN 92034001 and 92035000 ";


/*$sql = " INSERT INTO usr_deleg (app_id, dep_id, user_id) VALUES ('21', 6023, 265) ";*/

/*$sql = "DELETE FROM conciliacion_formularios
        WHERE repart_id = '1'
        AND articulo_id = '117'
        AND serie_id = '1'";*/


/*$sql = "DELETE FROM formularios_inexistentes
        WHERE repart_id = '1'
        AND articulo_id = '117'
        AND serie_id = '1'";
*/

/*
DELETE FROM conciliacion_formularios
WHERE repart_id = '1'
AND articulo_id = '117'
AND serie_id = '1'

DELETE FROM formularios_inexistentes
WHERE repart_id = '1'
AND articulo_id = '117'
AND serie_id = '1'
*/

/*$sql = "DELETE FROM mvtos_formularios
WHERE repart_id = '1'
AND articulo_id = '117'
AND serie_id = '1'";*/

/*$sql = "DELETE FROM rendicion_formularios
WHERE repart_id = '1'
AND articulo_id = '117'
AND serie_id = '1'";*/


/*$sql = "DELETE FROM detalle_formularios
WHERE repart_id = '1'
AND articulo_id = '117'
AND serie_id = '1'";*/




/*$sql = "DELETE FROM resumen_archivos WHERE ISNULL(cod_ente_recau)";*/
/*$sql = "DELETE FROM resumen_archivos WHERE nombre_archivo = 'pruebatito' ";*/

$result = mysql_query($sql, $conn->db);
if (!$result){
    $er = mysql_error($conn->db);
    $erno = mysql_errno($conn->db);
    mysql_query('ROLLBACK;', $conn->db);
    die("Error: #$erno <br/> $er <br/> $sql");
} else {
    mysql_query("COMMIT", $conn->db);
    echo "<h1>OK resumen</h1>";
}
mysql_close($conn->db);

?>
